<template>
  <view>
    <view class="special-work-list__group">
      <view class="special-work-list__item">
        <text class="special-work-list__label">项目编号：</text>
        <text class="special-work-list__value">{{ detail.workProjectResp.projectCode }}</text>
      </view>
      <view class="special-work-list__item">
        <text class="special-work-list__label">项目名称：</text>
        <text class="special-work-list__value">{{ detail.workProjectResp.projectName }}</text>
      </view>
      <view class="special-work-list__item">
        <text class="special-work-list__label">所属区域：</text>
        <text class="special-work-list__value">{{ detail.workProjectResp.areaName }}</text>
      </view>
      <view class="special-work-list__item">
        <text class="special-work-list__label">项目类型：</text>
        <text class="special-work-list__value">{{ detail.workProjectResp.projectTypeLabel }}</text>
      </view>
      <view class="special-work-list__item">
        <text class="special-work-list__label">项目负责部门：</text>
        <text class="special-work-list__value">{{ detail.workProjectResp.deptName }}</text>
      </view>
      <view class="special-work-list__item">
        <text class="special-work-list__label">项目日期：</text>
        <text class="special-work-list__value">{{ detail.workProjectInfoResp.projectDate }}</text>
      </view>
      <view class="special-work-list__item">
        <text class="special-work-list__label">项目负责人：</text>
        <text class="special-work-list__value">{{ detail.workProjectResp.directorName }}</text>
      </view>
      <view class="special-work-list__item">
        <text class="special-work-list__label">项目负责部门：</text>
        <text class="special-work-list__value">{{ detail.workProjectResp.deptName }}</text>
      </view>
      <view class="special-work-list__item">
        <text class="special-work-list__label">项目负责岗位：</text>
        <text class="special-work-list__value">{{ detail.workProjectResp.postName }}</text>
      </view>
      <view class="special-work-list__item">
        <text class="special-work-list__label">监护人：</text>
        <text class="special-work-list__value">{{ detail.workProjectResp.guardianName }}</text>
      </view>
      <view class="special-work-list__item">
        <text class="special-work-list__label">添加人：</text>
        <text class="special-work-list__value">{{ detail.workProjectResp.creator }}</text>
      </view>
      <view class="special-work-list__item">
        <text class="special-work-list__label">创建时间：</text>
        <text class="special-work-list__value">{{ createTime }}</text>
      </view>
      <view class="special-work-list__item">
        <text class="special-work-list__label">审批时间：</text>
        <text class="special-work-list__value">{{ checkTime }}</text>
      </view>
      <view class="special-work-list__item">
        <text class="special-work-list__label">现场研判人员：</text>
        <text class="special-work-list__value">{{ detail.workProjectInfoResp.judgmentUserName }}</text>
      </view>
      <view class="special-work-list__item flex-col">
        <text class="special-work-list__label">现场研判照片：</text>
        <view class="flex">
          <image
            v-for="image in judgmentPhotos"
            :key="image"
            :src="image"
            mode="aspectFill"
            class="special-work__img"
            @click="handlePreviewImage(image, judgmentPhotos)"
          ></image>
        </view>
      </view>
      <view class="special-work-list__item">
        <text class="special-work-list__label">项目描述：</text>
        <text class="special-work-list__value">{{ detail.workProjectResp.description }}</text>
      </view>
      <view class="special-work-list__item flex-col">
        <text class="special-work-list__label">安全管控方案：</text>
        <view class="flex">
          <image
            v-for="image in safetyControlCase"
            :key="image"
            :src="image"
            mode="aspectFill"
            class="special-work__img"
            @click="handlePreviewImage(image, safetyControlCase)"
          ></image>
        </view>
      </view>
      <view class="special-work-list__item">
        <text class="special-work-list__label">风险等级：</text>
        <text class="special-work-list__value">{{ detail.workProjectInfoResp.riskIdentificationResult }}</text>
      </view>
    </view>
  </view>
</template>

<script>
import dayjs from 'dayjs'
import { staticUrl } from '@/config'
export default {
  props: {
    detail: {
      type: Object,
      default: () => ({})
    }
  },
  computed: {
    checkTime() {
      if (this.detail.workProjectInfoResp?.checkTime) {
        return dayjs(this.detail.workProjectInfoResp.checkTime).format('YYYY-MM-DD HH:mm')
      }
      return '--'
    },
    createTime() {
      if (this.detail.workProjectInfoResp?.createTime) {
        return dayjs(this.detail.workProjectInfoResp.createTime).format('YYYY-MM-DD HH:mm')
      }
      return '--'
    },
    judgmentPhotos() {
      if (this.detail.workProjectInfoResp?.judgmentPhotos) {
        const arr = this.detail.workProjectInfoResp?.judgmentPhotos.split(',')
        return arr.map((item) => `${staticUrl}${item}`)
      }
      return []
    },
    safetyControlCase() {
      if (this.detail.workProjectInfoResp?.safetyControlCase) {
        const arr = this.detail.workProjectInfoResp?.safetyControlCase.split(',')
        return arr.map((item) => `${staticUrl}${item}`)
      }
      return []
    }
  },
  data() {
    return {
      staticUrl
    }
  },
  methods: {
    handlePreviewImage(url, urls) {
      uni.previewImage({
        current: url,
        urls: urls
      })
    }
  }
}
</script>

<style scoped lang="scss">
@import '../../detail/style/style.scss';
</style>
